<?php 


/**
* 
*/
class ku
{
	public $db;
	public $table;
	function __construct($table=null)
	{
		$this->table=$table;
		try{
		$this->db = new PDO("mysql:host=127.0.0.1;dbname=school1;charset=utf8","root","");
		}catch(PDOException  $e ){
			echo "Error: ".$e;
		}
	}
	public function query($sql)
	{
		$res = $this->db->query($sql);
		if(!$res){
			echo "执行失败：错误代码：".$this->db->errorCode()."错误信息：".$this->db->errorInfo()[2];
		}
		return $res->fetchAll(PDO::FETCH_ASSOC);
	}
	public function del($where)
	{
		$del = 'delete from '.$this->table.' where '.$where;
		$res = $this->db->query($del);
		var_dump($res);
		return $res;
	}
	public function add($a,$b)
	{
		$add = 'insert into '.$this->table. ' ('.$a.') values ('.$b.')';
		// var_dump($add);
		$res = $this->db->exec($add);
		return $res;
	}

}
















 ?>